package com.nic.view;

import android.content.Context;
import android.net.Uri;
import android.support.v4.content.FileProvider;

import com.nic.view.util.SystemPropertiesProxy;

import java.io.File;

/**
 * Created by Administrator on 2018/11/1.
 */

public class ViewConfig {
    public static Context applicationContext;
    public static String PACKAGE_NAME = "";//包名
    public static boolean DEBUG = true;
    public static String SDCARD_PATH = "sdcard/com.common.temp";//本地数据库名称
    public static int LOADING_IMG_ID = R.drawable.ic_loading;
    public static int LOADING_ERROR_ID = R.drawable.ic_loading_fail;
    public static String IP;
    public static String PORT;

    public static void init(Context context, String packageName, String rootPath, boolean isDebug) {
        applicationContext = context;
        PACKAGE_NAME = packageName;
        DEBUG = SystemPropertiesProxy.getBoolean(context, "persist.sys.lanjiulog.enable", true)||isDebug;
        SDCARD_PATH = rootPath;
    }

    public static void init(Context context, String packageName, String rootPath, boolean isDebug, int loadId, int loadErrId) {
        applicationContext = context;
        PACKAGE_NAME = packageName;
        DEBUG = SystemPropertiesProxy.getBoolean(context, "persist.sys.lanjiulog.enable", isDebug);
        SDCARD_PATH = rootPath;
        if (loadId != 0) {
            LOADING_IMG_ID = loadId;
        }
        if (loadErrId != 0) {
            LOADING_ERROR_ID = loadErrId;
        }

    }

    /**
     * provider 路径
     *
     * @param context
     * @param file
     * @return
     */
    public static Uri getFileProviderA7(Context context, File file) {
        return FileProvider.getUriForFile(context, context.getString(R.string.provider_path), file);
    }
}
